package main

import (
	"flag"
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"
)

func main() {
	var host string
	flag.StringVar(&host, "host", "", "proxy server host")
	flag.Parse()

	hostURL, _ := url.Parse(host)

	//http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
	//	director := func(req *http.Request) {
	//		//req = r
	//		req.URL.Scheme = "http"
	//		req.URL.Host = host
	//		req.Host = host
	//	}
	//	proxy := &httputil.ReverseProxy{Director: director}
	//	proxy.ServeHTTP(w, r)
	//})
	proxyHandler  := httputil.NewSingleHostReverseProxy(hostURL)
	log.Fatal(http.ListenAndServe(":80", proxyHandler))
}
